package com.ws.configuration;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class HttpInterceptorConfig implements WebMvcConfigurer {

    //给spring添加拦截器
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //拦截器管理对象 能配置拦截器监听的接口范围
        InterceptorRegistration lanjieqi = registry.addInterceptor(new LoginHandler());
        //监听当前项目下的所有请求路径
        lanjieqi.addPathPatterns("/**")
                .excludePathPatterns("/user/admin/login","/public/**")
                .excludePathPatterns("/user/shop/login/password")
                .excludePathPatterns("/user/shop/register");
    }
}
